import dayjs from 'dayjs'

export function compareDate(dateString: string) {
  const date = dayjs(dateString)
  const today = dayjs()
  const tomorrow = today.add(1, 'day')
  const yesterday = today.subtract(1, 'day')
  const dayBeforeYesterday = today.subtract(2, 'day')
  const dayAfterTomorrow = today.add(2, 'day')

  if (date.isSame(today, 'day'))
    return '今天'
  else if (date.isSame(yesterday, 'day'))
    return '昨天'
  else if (date.isSame(dayBeforeYesterday, 'day'))
    return '前天'
  else if (date.isSame(tomorrow, 'day'))
    return '明天'
  else if (date.isSame(dayAfterTomorrow, 'day'))
    return '后天'
  else
    return dateString
}
